﻿/* ===============================================================================  
 * Copyright (c) 2010 Acid Frameworks
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * 
 * =============================================================================== */

using Acid.Math;

namespace Acid.Rendering
{
    /// <summary>
    /// A ViewInfo is analogous to a Camera. It contains a View and Projection Matrix. It is referenced by a RenderNode, and itself references a Transform which contains Shapes, Primitives to be rendered.
    /// </summary>
    public class ViewInfo : IPackObject
    {
        private static int Count { get; set; }

        /// <summary>
        /// The Transform this ViewInfo points to.
        /// </summary>
        public Transform Transform { get; set; }
        /// <summary>
        /// The View Matrix
        /// </summary>
        public Matrix    View      { get; set; }
        /// <summary>
        /// The Projection Matrix
        /// </summary>
        public Matrix    Projection{ get; set; }

        public ViewInfo()
        {
            this.ID         = "viewInfo_" + ViewInfo.Count.ToString(); ViewInfo.Count++;
            
            this.Transform  = null;
            
            this.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), 1, 0.1f, 1000.0f);
            
            this.View       = Matrix.CreateLookAt(new Vector3(0, 0, 0),
                                                  new Vector3(0, 0, 1),
                                                  new Vector3(0, 1, 0));
            this.Projection = Matrix.Identity; 

        }

        #region IGraphObject Members
        /// <summary>
        /// This ViewInfo's ID
        /// </summary>
        public string ID { get; set; }
        /// <summary>
        /// This ViewInfos Name
        /// </summary>
        public string Name { get; set; }

        #endregion
    }
}
